home *** CD-ROM | disk | FTP | other *** search
/ New Star Software Collection / NSS_Collection.iso / 3-170 dbase 10 for windows / 1.ima / SAMPLES.PAK / TESTCLAS.PRG < prev    next >
Text File  |  1993-07-26  |  3KB  |  94 lines

  1. *******************************************************************************
  2. *  PROGRAM:      Testclas.prg
  3. *
  4. *  WRITTEN BY:   Borland Late Night Crew
  5. *
  6. *  DATE:         6/93
  7. *
  8. *  UPDATED:
  9. *
  10. *  VERSION:      Alpha α
  11. *
  12. *  DESCRIPTION:  This program shows how to define classes and their properties
  13. *                and methods using Bladerunner's object syntax.  It creates
  14. *                3 classes: MyClass -- has properties and methods,
  15. *                           BaseClass -- has one property
  16. *                           Derived   -- derived from BaseClass, contains
  17. *                                        on property of its own.
  18. *                It displays and sets the properties of these classes, and
  19. *                shows the results of the methods.
  20. *
  21. *  PARAMETERS:   None
  22. *
  23. *  CALLS:        None
  24. *
  25. *  USAGE:        DO Testclas
  26. *
  27. *******************************************************************************
  28. a = new myClass("parm")  && instance of myClass
  29.  
  30. * Display a's properties
  31. ? a.x
  32. ? a.y
  33. ? a.z
  34. ? a.goo()   && methods
  35. ? a.hoo()
  36. ? a.zoo()
  37. b = new myClass("parm")  && another instance of myClass
  38.  
  39. b.x = 56  && assign values to the properties of each class instance
  40. a.x = 89
  41.  
  42. c = new derived()  && instance of derived.  It will also contain the properties
  43.                    && of its parent class -- base
  44. ? c.basicVar
  45. ? c.extra
  46.  
  47.  
  48. *******************************************************************************
  49. class myClass
  50. *******************************************************************************
  51.    * Constructor
  52.    parameter p
  53.    this.x=4
  54.    this.y=5
  55.    this.z=p
  56.  
  57.    ***********************************************
  58.    function goo
  59.    ***********************************************
  60.    * member function
  61.    ? "hello,  my name is Goo"
  62.    return .t.
  63.  
  64.    ***********************************************
  65.    function hoo
  66.    ***********************************************
  67.    * member function
  68.    ? "hello,  my name is hoo"
  69.    return .t.
  70.  
  71.    ***********************************************
  72.    function zoo
  73.    ***********************************************
  74.    * member function
  75.    ? "hello,  my name is zoo"
  76.    return .t.
  77.  
  78. endclass
  79.  
  80. *******************************************************************************
  81. class base
  82. *******************************************************************************
  83.    this.basicVar = 1
  84. endclass
  85.  
  86.  
  87. *******************************************************************************
  88. class derived of base
  89. *******************************************************************************
  90.    this.extra = "Extra extra"
  91. endclass
  92.  
  93. ******************************* End of Testclas.prg ***************************
  94.